package com.cn.dao;

import com.cn.entity.TaoCan;
import com.cn.util.DBUtil;

import java.sql.ResultSet;
import java.sql.SQLException;

public class QueryTaoCandao {
    static ResultSet rs;
    static TaoCan taoCan=null;
    public static TaoCan queryTaoCan(int id) {
        String sql = "select * from TaoCan where id=?";
        Object[] obj = {id};
        rs = DBUtil.query(sql, obj);
        if(rs!=null) {
            try {
                if (rs.next()) {
                    int id1 = rs.getInt("id");
                    String name1 = rs.getString("name");
                    int time1 = rs.getInt("time");
                    int liuliang1 = rs.getInt("liuliang");
                    int message1 = rs.getInt("message");
                    double money1 = rs.getDouble("money");
                    String desc1 = rs.getString("desc");
                    taoCan = new TaoCan(id1, name1, time1, liuliang1, message1, money1, desc1);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return taoCan;
    }
}
